const root = {
    val: 'A',
    left: {
        val: 'B',
        left: {
            val: 'D'
        },
        right: {
            val: 'E'
        },
    },
    right: {
        val: 'C',
        left: {
            val: 'F',
        }
    }
}
var levelOrderBottom = function(root) {
  
    if(!root)return[]
    const queue=[]
    queue.push(root)
    const res=[]
    while(queue.length)
    {
        const arr=[]
        const len=queue.length
       for(let i=0;i<len;i++)
       {
         let top=queue.shift()
         arr.push(top.val)
         
        if(top.left){
            queue.push(top.left)
        }
         if(top.right){
            queue.push(top.right)
        }
        
       }
       
       res.push(arr)
    }
    res.reverse()
    return res
};
 console.log(levelOrderBottom(root))